using System.Collections;
using CommonLibrary.Exceptions;
using CommonLibrary.Helpers;

namespace CommonLibrary.Models.ControllerStates.PS3
{
    public class SixAxisButtons : ViewModel
    {
        private static SixaxiButton _select;
        public SixaxiButton Select
        {
            get { return _select ?? (_select = new SixaxiButton()); }
            set { _select = value;
            OnPropertyChanged("Select");
            }
        }

        private static SixaxiButton _start;
        public SixaxiButton Start
        {
            get { return _start ?? (_start = new SixaxiButton()); }
            set
            {
                _start = value; OnPropertyChanged("Start");
            }
        }

        private SixaxiButton _ps;
        public SixaxiButton PS
        {
            get { return _ps ?? (_ps = new SixaxiButton()); }
            set
            {
                _ps = value; OnPropertyChanged("PS");
            }
        }

        private SixaxiButton _up;
        public SixaxiButton Up
        {
            get { return _up ?? (_up = new SixaxiButton()); }
            set { _up = value; OnPropertyChanged("Up"); }
        }

        private SixaxiButton _right;
        public SixaxiButton Right
        {
            get { return _right ?? (_right = new SixaxiButton()); }
            set { _right = value; OnPropertyChanged("Right"); }
        }

        private SixaxiButton _down;
        public SixaxiButton Down
        {
            get { return _down ?? (_down = new SixaxiButton()); }
            set { _down = value; OnPropertyChanged("Down"); }
        }

        private SixaxiButton _left;
        public SixaxiButton Left
        {
            get { return _left ?? ( _left = new SixaxiButton()); }
            set { _left = value; OnPropertyChanged("Left"); }
        }

        private SixaxiButton _triangle;
        public SixaxiButton Triangle
        {
            get { return _triangle ?? (_triangle = new SixaxiButton()); }
            set { _triangle = value; OnPropertyChanged("Triangle"); }
        }

        private SixaxiButton _circle;
        public SixaxiButton Circle
        {
            get { return _circle ?? (_circle = new SixaxiButton()); }
            set { _circle = value; OnPropertyChanged("Circle"); }
        }

        private SixaxiButton _cross;
        public SixaxiButton Cross
        {
            get { return _cross ?? (_cross = new SixaxiButton()); }
            set { _cross = value; OnPropertyChanged("Cross"); }
        }

        private SixaxiButton _square;
        public SixaxiButton Square
        {
            get { return _square ?? (_square = new SixaxiButton()); }
            set { _square = value; OnPropertyChanged("Square"); }
        }

        private SixaxiButton _l1;
        public SixaxiButton L1
        {
            get { return _l1 ?? (_l1 = new SixaxiButton()); }
            set { _l1 = value; OnPropertyChanged("L1"); }
        }

        private SixaxiButton _l2;
        public SixaxiButton L2
        {
            get { return _l2 ?? (_l2 = new SixaxiButton()); }
            set { _l2 = value; OnPropertyChanged("L2"); }
        }

        private SixaxiButton _l3;
        public SixaxiButton L3
        {
            get { return _l3 ?? (_l3 = new SixaxiButton()); }
            set { _l3 = value; OnPropertyChanged("L3"); }
        }

        private SixaxiButton _r1;
        public SixaxiButton R1
        {
            get { return _r1 ?? (_r1 = new SixaxiButton()); }
            set { _r1 = value; OnPropertyChanged("R1"); }
        }

        private SixaxiButton _r2;
        public SixaxiButton R2
        {
            get { return _r2 ?? (_r2 = new SixaxiButton()); }
            set { _r2 = value; OnPropertyChanged("R2"); }
        }

        private SixaxiButton _r3;
        public SixaxiButton R3
        {
            get { return _r3 ?? (_r3 = new SixaxiButton()); }
            set { _r3 = value; OnPropertyChanged("R3"); }
        }

       public SixaxiButton GetInDigitalOrder(int buttonNr)
       {
           switch (buttonNr)
           {
               case 0:
                   return Select;
               case 1:
                   return L3;
               case 2:
                   return R3;
               case 3:
                   return Start;
               case 4:
                   return Up;
               case 5:
                   return Right;
               case 6:
                   return Down;
               case 7:
                   return Left;
               case 8:
                   return L2;
               case 9:
                   return R2;
               case 10:
                   return L1;
               case 11:
                   return R1;
               case 12:
                   return Triangle;
               case 13:
                   return Circle;
               case 14:
                   return Cross;
               case 15:
                   return Square;
               case 16:
                   return PS;
           }
           throw new SimpleSmartException("What button are you asking for?");
       }

       public SixaxiButton GetInAnalogOrder(int buttonNr)
       {
           switch (buttonNr)
           {
               case 0:
                   return Up;
               case 1:
                   return Right;
               case 2:
                   return Down;
               case 3:
                   return Left;
               case 4:
                   return L2;
               case 5:
                   return R2;
               case 6:
                   return L1;
               case 7:
                   return R1;
               case 8:
                   return Triangle;
               case 9:
                   return Circle;
               case 10:
                   return Cross;
               case 11:
                   return Square;
           }
           throw new SimpleSmartException("What button are you asking for?");
       }
    }
}